﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Tatara;
using System.IO;

namespace Kurogane.Compiler {

	public class AnotherParser {

		private static readonly Parser<char> _半角数字 = Parsers.OneChar(c => '0' <= c && c <= '9');
		private static readonly Parser<char> _全角数字 = Parsers.OneChar(c => '０' <= c && c <= '９').Select(c => (char)(c - '０' + '0'));
		private static readonly Parser<char> _数字 = _半角数字 | _全角数字;

		private static readonly Parser<char> _ひらがな = Parsers.OneChar(c => 'ぁ' <= c && c <= 'ん');
		private static readonly Parser<char> _Nonひらがな = Parsers.OneChar(c => Char.IsLetter(c) && (c < 'ぁ' || 'ん' < c));

		private static readonly Parser<int> _整数 =
			from c in _数字.Repeat(1)
			select Int32.Parse(new string(c.ToArray()));

		private static readonly Parser<double> _少数 =
			from i in _数字.Repeat()
			from dot in Parsers.OneChar(c => c == '.' || c == '．')
			from f in _数字.Repeat(1)
			select Double.Parse(new string(i.Concat(".").Concat(f).ToArray()));

		private static readonly Parser<string> _文字列 =
			from s in Parsers.OneChar(c => c == '「')
			from str in Parsers.OneChar(c => c != '」').Repeat()
			from e in Parsers.OneChar(c => c == '」')
			select new string(str.ToArray());

		private static readonly Parser<bool> _真 = Parsers.Constant(ConstantNames.TrueText).Select(str => true);
		private static readonly Parser<bool> _偽 =
			(Parsers.Constant(ConstantNames.FalseText) | Parsers.Constant(ConstantNames.ElseText)).Select(str => true);
		private static readonly Parser<bool> _真偽値 = _真 | _偽;

		public static Block Parse(TextReader reader) {

			throw new NotImplementedException();
		}
	}
}
